<%= content_for :title, "Clusters ##{@cluster.id}" %>
<%= turbo_stream_from @cluster %>

<%= cluster_layout(@cluster) do %>
  <div id="<%= dom_id @cluster %>">
    <div class="grid grid-cols-2 gap-4">
      <%= link_to download_kubeconfig_cluster_path(@cluster), class: "btn btn-sm btn-outline", target: "_blank" do %>
        <div class="flex items-center gap-2">
          Download Kubeconfig File
        </div>
      <% end %>
      <%= link_to download_yaml_cluster_path(@cluster), class: "btn btn-sm btn-outline", target: "_blank" do %>
        <div class="flex items-center gap-2">
          Download All YAML Files
        </div>
      <% end %>
    </div>

    <div class="mt-4">
      <h6 class="text-xl font-bold">Configuration</h6>
      <div class="mb-4">
        <%= render(
          "shared/partials/async_renderer",
          view_model: Async::K8::ConfigurationViewModel.new(
            current_user,
            cluster_id: @cluster.id
          )
        ) %>
      </div>
    </div>

    <% if @cluster.projects.any? %>
      <h4 class="mt-4 text-2xl font-bold">Projects</h4>
      <hr class="mt-2 mb-6 border-base-content/10" />
      <div class="grid grid-cols-2 lg:grid-cols-4 gap-4">
        <% @cluster.projects.each do |project| %>
          <%= render project %>
        <% end %>
      </div>
    <% end %>
    <% if @cluster.add_ons.any? %>
      <h4 class="mt-4 text-2xl font-bold">Add Ons</h4>
      <hr class="mt-2 mb-6 border-base-content/10" />
      <div class="grid grid-cols-1 lg:grid-cols-4 gap-4">
      <% @cluster.add_ons.each do |add_on| %>
        <%= render add_on %>
      <% end %>
      </div>
    <% end %>
    <h6 class="mt-4 text-xl font-bold">Install Logs</h6>
    <div class="collapse">
      <input aria-label="Accordion radio" type="checkbox" name="accordion" class="w-full">
      <div class="collapse-title p-0 underline m-0">Show install logs</div>
      <div class="collapse-content p-0 mt-2">
        <%= render "log_outputs/logs", loggable: @cluster %>
      </div>
    </div>
  </div>
<% end %>